{% extends "base.html" %}

{% block content %}
<div class="container mt-4">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">编辑用户</h3>
                </div>
                <div class="card-body">
                    <form method="POST">
                        <div class="mb-3">
                            <label for="username" class="form-label">用户名</label>
                            <input type="text" class="form-control" id="username" value="{{ user.username }}" disabled>
                        </div>
                        <div class="mb-3">
                            <label for="email" class="form-label">邮箱</label>
                            <input type="email" class="form-control" id="email" name="email" value="{{ user.email }}" required>
                        </div>
                        <div class="mb-3">
                            <label for="password" class="form-label">密码 (留空表示不修改)</label>
                            <input type="password" class="form-control" id="password" name="password">
                        </div>
                        <div class="mb-3">
                            <label for="role" class="form-label">角色</label>
                            <select class="form-select" id="role" name="role" required>
                                <option value="admin" {% if user.role == 'admin' %}selected{% endif %}>管理员</option>
                                <option value="researcher" {% if user.role == 'researcher' %}selected{% endif %}>科研人员</option>
                                <option value="logistics" {% if user.role == 'logistics' %}selected{% endif %}>物流人员</option>
                                <option value="finance" {% if user.role == 'finance' %}selected{% endif %}>财务人员</option>
                                <option value="service" {% if user.role == 'service' %}selected{% endif %}>售后服务人员</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" id="status" name="status" {% if user.status %}checked{% endif %}>
                                <label class="form-check-label" for="status">启用状态</label>
                            </div>
                        </div>
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary">保存修改</button>
                            <a href="{{ url_for('user.user_list') }}" class="btn btn-secondary">返回</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 